<?php
if(defined('IZ_ACCNAME')) {
  if($_SESSION['canview'] == 1) {
    $cals .= 'Calendar.setup({inputField:"reportfrom",displayArea:"reportfrommousehook",button:"reportfrommousehook",firstDay:JS_FIRSTDAY});'."\n".
             'Calendar.setup({inputField:"reportto",displayArea:"reporttomousehook",button:"reporttomousehook",firstDay:JS_FIRSTDAY});'."\n";
    if(isset($_GET['reportfrom'])) { 
      $reportfrom = $_GET['reportfrom'];
    } else {
      list($d,$m,$y) = explode('/',date('j/m/Y',mktime()));
      $reportfrom = date('j/m/Y',mktime(0,0,0,$m-1,$d,$y));
    }
    if(isset($_GET['reportto'])) { 
      $reportto = $_GET['reportto'];
    } else {
      $reportto = date('j/m/Y',mktime());
    }
    if(isset($_GET['type'])) {
      $type = $_GET['type'];
    } else {
      $type = 'usage';
    }
    ?>
    <div id="reports">
      <h1 class="left"><?php echo STR_REPORTS; ?></h1>
      <form enctype="multipart/form-data" method="get" action="<?php echo $_SESSION['IZ_CALURL']; ?>index.php" id="reportsform" name="reportsform" onsubmit="return true; /*validate_reports();*/">
        <fieldset>
          <legend><?php echo STR_REPORTCRITERIA; ?></legend>
          <label for="reportfromstartbox"><?php echo STR_FROM; ?>&#58;</label>
          <div class="datebox" id="reportfromstartbox">
              <div class="dateinput">
                  <input type="text" name="reportfrom" tabindex="2" size="10" id="reportfrom" class="standard" value="<?php echo $reportfrom ?>" />
                  <img src="<?php echo $_SESSION['IZ_CALURL']; ?>images/calendar.png" class="datepicker" alt="<?php echo STR_PICKSTART; ?>" id="reportfrommousehook" />
              </div>
          </div>
          <br />
  
          <label for="reporttobox"><?php echo STR_TO; ?>&#58;</label>
          <div class="datebox" id="reporttobox">
              <div class="dateinput">
                <input type="text" name="reportto" tabindex="4" size="10" id="reportto" class="standard" value="<?php echo $reportto ?>" />
                <img src="<?php echo $_SESSION['IZ_CALURL']; ?>images/calendar.png" class="datepicker" alt="<?php echo STR_PICKEND; ?>" id="reporttomousehook" />
              </div>
          </div>
          <br />
          
          <label><?php echo STR_CATEGORIES; ?>&#58;</label>
          <fieldset class="categories">
            <legend><?php echo STR_CALENDAR; ?></legend>
            <ul class="categorylist">
            <?php
              foreach($_SESSION['eventcats'] as $cat) {
                if(!empty($cat)) {
                  echo '<li><input type="checkbox" name="ce_',$cat->id,'" id="ce_',$cat->id,'" value="1" ',($_GET['ce_'.$cat->id] == 1 || !isset($_GET['generate']) ? 'checked="checked"' : ''),' /><label for="ce_',$cat->id,'">',$cat->name,'</label></li>'."\n";
                }
              }
            ?>
            </ul>
          </fieldset>
          <?php if(($_SESSION['IZ_OPT'] & OPT_TODO) != 0) { ?>
            <fieldset class="categories">
              <legend><?php echo STR_TASKS; ?></legend>
              <ul class="categorylist">
              <?php
                foreach($_SESSION['todocats'] as $cat) {
                  if(!empty($cat)) {
                    echo '<li><input type="checkbox" name="ct_',$cat->id,'" id="ct_',$cat->id,'" value="1" ',($_GET['ct_'.$cat->id] == 1 || !isset($_GET['generate']) ? 'checked="checked"' : ''),' /><label for="ct_',$cat->id,'">',$cat->name,'</label></li>'."\n";
                  }
                }
              ?>
              </ul>
            </fieldset>
          <?php } ?>
          <div style="clear: both;"></div>
          
          <label><?php echo STR_REPORTTYPE; ?>&#58;</label>
          <div class="checks">
            <input type="radio" value="usage" name="type" tabindex="6" class="nomargin" id="reporttimeusage"<?php if($type == 'usage') { echo ' checked="checked"'; } ?> /><label for="reporttimeusage" class="plain"><?php echo STR_TIMEUSAGE; ?></label>
            <input type="radio" value="number" name="type" tabindex="7" class="nomargin" id="reportnumitems"<?php if($type == 'number') { echo ' checked="checked"'; } ?> /><label for="reportnumitems" class="plain"><?php echo STR_NUMITEMS; ?></label>
          </div><br />
          
          <button type="submit" value="1" tabindex="10" name="generate" class="buttonreport"><?php echo STR_GENERATE; ?></button>
          <input type="hidden" value="report" name="act" />
        </fieldset>
      </form>
      <?php if(isset($_GET['generate'])) {
        izsql();
//        include($_SESSION['IZ_CALPATH'].'includes/lib/ofc/php-ofc-library/open-flash-chart.php');
        include($_SESSION['IZ_CALPATH'].'includes/lib/fusion/FusionCharts_Gen.php');
        $coloursPossible = array(
          array(
           'E89F80',
           '8D9669',
           '9C4B1F',
           'D4CFB8',
           '2B1204',
          ),
          array(
           '77A240',
           'FCCB48',
           'D4E889',
           '2B2A19',
           '425813',
          ),
          array(
           'F05535',
           'F5E09E',
           '69AFA8',
           'DD2640',
           'F05535',
          ),
          array(
           '365773',
           'EDFFA6',
           'A8DFB7',
           'C23014',
           'D5EB7C',
          ),
          array(
           'FF6454',
           'E99F00',
           '4BB400',
           '1388FF',
           'DD009A',
          ),
        );
        $colours = $coloursPossible[mt_rand(0,count($coloursPossible)-1)];
        list($fromday,$frommonth,$fromyear) = explode('/',$reportfrom);
        $fromsecs = mktime(0,0,0,intval($frommonth),intval($fromday),intval($fromyear));
        list($today,$tomonth,$toyear) = explode('/',$reportto);
        $tosecs = mktime(23,59,59,intval($tomonth),intval($today)+1,intval($toyear)); // must include events ON the ending day
        $prettyreportfrom = date($_SESSION['dateformat'], $fromsecs);
//echo $prettyreportfrom.'-'.$fromsecs.'='.intval($frommonth),intval($fromday),intval($fromyear).'#'.$_SESSION['DATEFORMAT'];
        $prettyreportto = date($_SESSION['dateformat'], $tosecs);
        if($_SESSION['cpanel'] == 1) {
          $eventsqlformat = 'SELECT * FROM events WHERE eventstart >= \'%s\' AND eventstart <= \'%s\' AND (category = \'%s\')';
          $tasksqlformat = 'SELECT * FROM tasks WHERE due >= \'%s\' AND due <= \'%s\' AND (category = \'%s\')';
        } else {
          $eventsqlformat = 'SELECT * FROM events WHERE eventstart >= \'%s\' AND eventstart <= \'%s\' AND (LOWER(author) = \''.strtolower($_SESSION['uname']).'\''.$_SESSION['publicstatus'].') AND (category = \'%s\')';
          $tasksqlformat = 'SELECT * FROM tasks WHERE due >= \'%s\' AND due <= \'%s\' AND (LOWER(author) = \''.strtolower($_SESSION['uname']).'\''.$_SESSION['publicstatus'].') AND (category = \'%s\')';
        }
        switch($type) {
          case 'usage':
            if(IZ_CALMODE == 'mysql') {
              if($_SESSION['MYSQLi']) {
                global $dblink;
                foreach($_GET as $catID => $status) {
                  $safeCatID = $dblink->real_escape_string($catID);
                  switch(substr($catID,0,2)) {
                    case 'ce':
                      $selectedEventCats[] = substr($safeCatID,3);
                      break;
                  }
                }
                if(is_array($selectedEventCats)) {
                  $selectedEventCatSQL = implode($selectedEventCats,'\' OR category = \'');
                  $eventsql = sprintf($eventsqlformat,
                                      $dblink->real_escape_string($fromsecs),
                                      $dblink->real_escape_string($tosecs),
                                      $selectedEventCatSQL
                                      );
                  $eventres = $dblink->query($eventsql);
                  if($eventres->num_rows > 0) {
                    while($sqlevent = $eventres->fetch_object()) {
                      if($sqlevent->allday == 1) {
                        $eventusage[$sqlevent->category] += ($sqlevent->eventend - $sqlevent->eventstart)+86400;
                      } else {
                        $eventusage[$sqlevent->category] += $sqlevent->eventend - $sqlevent->eventstart;
                      }
                    }
                  }
                } else {
                  iz_inlineerror(ERR_NOCATSELECTED);
                  $error = true;
                }
              } else {
                foreach($_GET as $catID => $status) {
                  $safeCatID = mysql_real_escape_string($catID);
                  switch(substr($catID,0,2)) {
                    case 'ce':
                      $selectedEventCats[] = substr($safeCatID,3);
                      break;
                  }
                }
                if(is_array($selectedEventCats)) {
                  $selectedEventCatSQL = implode($selectedEventCats,'\' OR category = \'');
                  $eventsql = sprintf($eventsqlformat,
                                      mysql_real_escape_string($fromsecs),
                                      mysql_real_escape_string($tosecs),
                                      $selectedEventCatSQL
                                      );
                  $eventqry = mysql_query($eventsql);
                  if((is_resource($eventqry)) && (mysql_num_rows($eventqry) > 0)) {
                    while($sqlevent = mysql_fetch_object($eventqry)) {
                      if($sqlevent->allday == 1) {
                        $eventusage[$sqlevent->category] += ($sqlevent->eventend - $sqlevent->eventstart)+86400;
                      } else {
                        $eventusage[$sqlevent->category] += $sqlevent->eventend - $sqlevent->eventstart;
                      }
                    }
                  }
                } else {
                  iz_inlineerror(ERR_NOCATSELECTED);
                  $error = true;
                }
              }
            } elseif(IZ_CALMODE == 'postgre') {
              foreach($_GET as $catID => $status) {
                  $safeCatID = pg_escape_string($catID);
                  switch(substr($catID,0,2)) {
                    case 'ce':
                      $selectedEventCats[] = substr($safeCatID,3);
                      break;
                  }
                }
                if(is_array($selectedEventCats)) {
                  $selectedEventCatSQL = implode($selectedEventCats,'\' OR category = \'');
                  $eventsql = sprintf($eventsqlformat,
                                      pg_escape_string($fromsecs),
                                      pg_escape_string($tosecs),
                                      $selectedEventCatSQL
                                      );
                  $eventqry = pg_query($eventsql);
                  if((is_resource($eventqry)) && (pg_num_rows($eventqry) > 0)) {
                     while($sqlevent = pg_fetch_object($eventqry)) {
                      if($sqlevent->allday == 1) {
                        $eventusage[$sqlevent->category] += ($sqlevent->eventend - $sqlevent->eventstart)+86400;
                      } else {
                        $eventusage[$sqlevent->category] += $sqlevent->eventend - $sqlevent->eventstart;
                      }
                    }
                  }
                } else {
                  iz_inlineerror(ERR_NOCATSELECTED);
                  $error = true;
                }
            } elseif(IZ_CALMODE == 'msq') {
              foreach($_GET as $catID => $status) {
                  $safeCatID = mssql_escape_string($catID);
                  switch(substr($catID,0,2)) {
                    case 'ce':
                      $selectedEventCats[] = substr($safeCatID,3);
                      break;
                  }
                }
                if(is_array($selectedEventCats)) {
                  $selectedEventCatSQL = implode($selectedEventCats,'\' OR category = \'');
                  $eventsql = sprintf($eventsqlformat,
                                      mssql_escape_string($fromsecs),
                                      mssql_escape_string($tosecs),
                                      $selectedEventCatSQL
                                      );
                  $eventqry = mssql_query($eventsql);
                  if((is_resource($eventqry)) && (mssql_num_rows($eventqry) > 0)) {
                    while($sqlevent = mssql_fetch_object($eventqry)) {
                      if($sqlevent->allday == 1) {
                        $eventusage[$sqlevent->category] += ($sqlevent->eventend - $sqlevent->eventstart)+86400;
                      } else {
                        $eventusage[$sqlevent->category] += $sqlevent->eventend - $sqlevent->eventstart;
                      }
                    }
                  }
                } else {
                  iz_inlineerror(ERR_NOCATSELECTED);
                  $error = true;
                }
            }
            if(!$error) {
              if(count($eventusage) > 0) {
                $eventschart = new FusionCharts("Pie3D","600","300"); 
               	$eventschart->setSwfPath($_SESSION['IZ_CALURL'].'includes/lib/fusion/');
               	$eventschart->setChartParams('caption='.STR_USAGEBYCAT.';subcaption='.$prettyreportfrom.' - '.$prettyreportto.';PYAxisName=Category;SYAxisName=Time Spent (Seconds);showNames=1;showValues=0;pieYScale=45;pieSliceDepth=20;bgColor='.CHARTBACKGROUND.';decimalPrecision=0;');
               	$i = 0;
               	$colornum = 0;
                $colours = $coloursPossible[mt_rand(0,count($coloursPossible)-1)];
                foreach($eventusage as $id => $usage) {
                  if(empty($_SESSION['eventcats'][$id]->name)) {
                    $eventschart->addChartData($usage,'name='.STR_PRIVATE.';color='.$colours[$colornum].';hoverText='.calcduration(0, $usage));
                  } else {
                    $eventschart->addChartData($usage,'name='.$_SESSION['eventcats'][$id]->name.';color='.$colours[$colornum].';hoverText='.calcduration(0, $usage).';link='.$_SESSION['IZ_CALURL'].'%3Fcategory%3D'.$id);
                  }
                  $i++;
                  if($colornum == 4) {
                    $colornum = 0;
                  } else {
                    $colornum++;
                  }
                }
              }
            }
            break;
          case 'number':
            if(IZ_CALMODE == 'mysql') {
              if($_SESSION['MYSQLi']) {
                global $dblink;
                foreach($_GET as $catID => $status) {
                  $safeCatID = $dblink->real_escape_string($catID);
                  switch(substr($catID,0,2)) {
                    case 'ce':
                      $selectedEventCats[] = substr($safeCatID,3);
                      break;
                    case 'ct':
                      $selectedTaskCats[] = substr($safeCatID,3);
                      break;
                  }
                }
                if(is_array($selectedEventCats)) {
                  $selectedEventCatSQL = implode($selectedEventCats,'\' OR category = \'');
                  $eventsql = sprintf($eventsqlformat,
                                      $dblink->real_escape_string($fromsecs),
                                      $dblink->real_escape_string($tosecs),
                                      $selectedEventCatSQL
                                      );
                  $eventres = $dblink->query($eventsql);
                  if($eventres->num_rows > 0) {
                    while($sqlevent = $eventres->fetch_object()) {
                      $eventusage[$sqlevent->category]++;
                    }
                  }
                  if(($_SESSION['IZ_OPT'] & OPT_TODO) != 0) {
                    if(is_array($selectedTaskCats)) {
                      $selectedTaskCatSQL = implode($selectedTaskCats,'\' OR category = \'');
                      $tasksql = sprintf($tasksqlformat,
                                          $dblink->real_escape_string($fromsecs),
                                          $dblink->real_escape_string($tosecs),
                                          $selectedTaskCatSQL
                                          );
                      $taskres = $dblink->query($tasksql);
                      if($taskres->num_rows > 0) {
                        while($sqltask = $taskres->fetch_object()) {
                          $taskusage[$sqltask->category]++;
                        }
                      }
                    } else {
                      iz_inlineerror(ERR_NOCATSELECTED);
                      $error = true;
                    }

                  }
                } else {
                  iz_inlineerror(ERR_NOCATSELECTED);
                  $error = true;
                }
              } else {
                foreach($_GET as $catID => $status) {
                  $safeCatID = mysql_real_escape_string($catID);
                  switch(substr($catID,0,2)) {
                    case 'ce':
                      $selectedEventCats[] = substr($safeCatID,3);
                      break;
                    case 'ct':
                      $selectedTaskCats[] = substr($safeCatID,3);
                      break;
                  }
                }
                if(is_array($selectedEventCats)) {
                  $selectedEventCatSQL = implode($selectedEventCats,'\' OR category = \'');
                  $eventsql = sprintf($eventsqlformat,
                                      mysql_real_escape_string($fromsecs),
                                      mysql_real_escape_string($tosecs),
                                      $selectedEventCatSQL
                                      );
                  $eventqry = mysql_query($eventsql);
                  if((is_resource($eventqry)) && (mysql_num_rows($eventqry) > 0)) {
                    while($sqlevent = mysql_fetch_object($eventqry)) {
                      $eventusage[$sqlevent->category]++;
                    }
                  }
                  if(($_SESSION['IZ_OPT'] & OPT_TODO) != 0) {
                    if(is_array($selectedTaskCats)) {
                      $selectedTaskCatSQL = implode($selectedTaskCats,'\' OR category = \'');
                      $tasksql = sprintf($tasksqlformat,
                                         mysql_real_escape_string($fromsecs),
                                         mysql_real_escape_string($tosecs),
                                         $selectedTaskCatSQL
                                         );
                      $taskres = mysql_query($tasksql);
                      if(is_resource($taskres) && mysql_num_rows($taskres) > 0) {
                        while($sqltask = mysql_fetch_object($taskres)) {
                          $taskusage[$sqltask->category]++;
                        }
                      }
                    } else {
                      iz_inlineerror(ERR_NOCATSELECTED);
                      $error = true;
                    }

                  }
                } else {
                  iz_inlineerror(ERR_NOCATSELECTED);
                  $error = true;
                }
              }
            } elseif(IZ_CALMODE == 'postgre') {
              foreach($_GET as $catID => $status) {
                  $safeCatID = pg_escape_string($catID);
                  switch(substr($catID,0,2)) {
                    case 'ce':
                      $selectedEventCats[] = substr($safeCatID,3);
                      break;
                    case 'ct':
                      $selectedTaskCats[] = substr($safeCatID,3);
                      break;
                  }
                }
                if(is_array($selectedEventCats)) {
                  $selectedEventCatSQL = implode($selectedEventCats,'\' OR category = \'');
                  $eventsql = sprintf($eventsqlformat,
                                      pg_escape_string($fromsecs),
                                      pg_escape_string($tosecs),
                                      $selectedEventCatSQL
                                      );
                  $eventqry = pg_query($eventsql);
                  if((is_resource($eventqry)) && (pg_num_rows($eventqry) > 0)) {
                     while($sqlevent = pg_fetch_object($eventqry)) {
                       $eventusage[$sqlevent->category]++;
                     }
                  }
                  if(($_SESSION['IZ_OPT'] & OPT_TODO) != 0) {
                    if(is_array($selectedTaskCats)) {
                      $selectedTaskCatSQL = implode($selectedTaskCats,'\' OR category = \'');
                      $tasksql = sprintf($tasksqlformat,
                                         pg_escape_string($fromsecs),
                                         pg_escape_string($tosecs),
                                         $selectedTaskCatSQL
                                         );
                      $taskres = pg_query($tasksql);
                      if(is_resource($taskres) && pg_num_rows($taskres) > 0) {
                        while($sqltask = pg_fetch_object($taskres)) {
                          $taskusage[$sqltask->category]++;
                        }
                      }
                    } else {
                      iz_inlineerror(ERR_NOCATSELECTED);
                      $error = true;
                    }

                  }
                } else {
                  iz_inlineerror(ERR_NOCATSELECTED);
                  $error = true;
                }
            } elseif(IZ_CALMODE == 'msq') {
              foreach($_GET as $catID => $status) {
                  $safeCatID = mssql_escape_string($catID);
                  switch(substr($catID,0,2)) {
                    case 'ce':
                      $selectedEventCats[] = substr($safeCatID,3);
                      break;
                    case 'ct':
                      $selectedTaskCats[] = substr($safeCatID,3);
                      break;
                  }
                }
                if(is_array($selectedEventCats)) {
                  $selectedEventCatSQL = implode($selectedEventCats,'\' OR category = \'');
                  $eventsql = sprintf($eventsqlformat,
                                      mssql_escape_string($fromsecs),
                                      mssql_escape_string($tosecs),
                                      $selectedEventCatSQL
                                      );
                  $eventqry = mssql_query($eventsql);
                  if((is_resource($eventqry)) && (mssql_num_rows($eventqry) > 0)) {
                    while($sqlevent = mssql_fetch_object($eventqry)) {
                      $eventusage[$sqlevent->category]++;
                    }
                  }
                  if(($_SESSION['IZ_OPT'] & OPT_TODO) != 0) {
                    if(is_array($selectedTaskCats)) {
                      $selectedTaskCatSQL = implode($selectedTaskCats,'\' OR category = \'');
                      $tasksql = sprintf($tasksqlformat,
                                         mssql_escape_string($fromsecs),
                                         mssql_escape_string($tosecs),
                                         $selectedTaskCatSQL
                                         );
                      $taskres = mssql_query($tasksql);
                      if(is_resource($taskres) && mssql_num_rows($taskres) > 0) {
                        while($sqltask = mssql_fetch_object($taskres)) {
                          $taskusage[$sqltask->category]++;
                        }
                      }
                    } else {
                      iz_inlineerror(ERR_NOCATSELECTED);
                      $error = true;
                    }
                  }
                } else {
                  iz_inlineerror(ERR_NOCATSELECTED);
                  $error = true;
                }
            }
            $i = 0;
            if(count($eventusage) > 0) {
              $eventschart = new FusionCharts("Pie3D","600","300"); 
             	$eventschart->setSwfPath($_SESSION['IZ_CALURL'].'includes/lib/fusion/');
             	$eventschart->setChartParams('caption='.STR_NUMITEMS.' ('.STR_EVENTS.');subcaption='.$prettyreportfrom.' - '.$prettyreportto.';PYAxisName=Category;SYAxisName=Number of Items;showNames=1;showValues=0;pieYScale=45;pieSliceDepth=20;bgColor='.CHARTBACKGROUND.';decimalPrecision=0;');
             	$i = 0;
             	$colornum = 0;
              $colours = $coloursPossible[mt_rand(0,count($coloursPossible)-1)];
              foreach($eventusage as $id => $usage) {
                if(empty($_SESSION['eventcats'][$id]->name)) {
                  $eventschart->addChartData($usage,'name='.STR_PRIVATE.';color='.$colours[$colornum].';hoverText='.calcduration(0, $usage));
                } else {
                  $eventschart->addChartData($usage,'name='.$_SESSION['eventcats'][$id]->name.';color='.$colours[$colornum].';hoverText='.calcduration(0, $usage).';link='.$_SESSION['IZ_CALURL'].'%3Fcategory%3D'.$id);
                }
                $i++;
                if($colornum == 4) {
                  $colornum = 0;
                } else {
                  $colornum++;
                }
              }
            }
            if(($opt_flags & OPT_TODO) != 0) {
              if(count($taskusage) > 0) {
                $taskschart = new FusionCharts("Pie3D","600","300"); 
               	$taskschart->setSwfPath($_SESSION['IZ_CALURL'].'includes/lib/fusion/');
               	$taskschart->setChartParams('caption='.STR_NUMITEMS.' ('.STR_TASKS.');subcaption='.$prettyreportfrom.' - '.$prettyreportto.';PYAxisName=Category;SYAxisName=Number of Items;showNames=1;showValues=0;pieYScale=45;pieSliceDepth=20;bgColor='.CHARTBACKGROUND.';decimalPrecision=0');
               	$i = 0;
               	$colornum = 0;
               	$colours = $coloursPossible[mt_rand(0,count($coloursPossible)-1)];
                foreach($taskusage as $id => $usage) {
                  if(empty($_SESSION['todocats'][$id]->name)) {
                    $taskschart->addChartData($usage,'name='.STR_PRIVATE.';color='.$colours[$colornum].';hoverText='.calcduration(0, $usage));
                  } else {
                    $taskschart->addChartData($usage,'name='.$_SESSION['todocats'][$id]->name.';color='.$colours[$colornum].';hoverText='.calcduration(0, $usage).';link='.$_SESSION['IZ_CALURL'].'%3Fcategory%3D'.$id);
                  }
                  $i++;
                  if($colornum == 4) {
                    $colornum = 0;
                  } else {
                    $colornum++;
                  }
                }
              }
            }
            break;
        } ?>
        <fieldset>
          <legend><?php echo STR_CHARTS; ?></legend>
          <div class="chart"><?php if($eventschart) { $eventschart->renderChart(); } else { echo '<strong>'.STR_NOEVENTSFOUND.'</strong>'; } ?></div>
          <?php if(($_SESSION['IZ_OPT'] & OPT_TODO) != 0 && $_GET['type'] == 'number') { ?>
            <div class="chart"><?php if($taskschart) { $taskschart->renderChart(); } else { echo '<strong>'.STR_NOTASKSFOUND.'</strong>'; } ?></div>
          <?php } ?>
        </fieldset>
        <script type="text/javascript">
        <?php echo $chartjs; ?>
        </script>
<?php } ?>
    </div><!-- end report -->
<?php 
  } else {
    echo '<span>&#35;220&#58; ',ERR_NOPERMISSION,'</span>';
  } 
} else {
  // Directly accessed
  header('Location: ../');
} ?>